﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GCELibrary.Current;

using System.Linq.Dynamic;
using System.Linq.Expressions;
using ZF.BLL.Linq;
using ZF.BLL;

namespace ZF.WS.shop
{
    public partial class info : BLL.Page.PageBase
    {
        [PageArgument(Key = "id", CanNull = false)]
        public int MercId { get; set; }
        private Model.SP_Merchandise _Merc = null;
        public Model.SP_Merchandise Merc { get { return _Merc; } set { _Merc = this.header1.Merc = value; } }
        private Model.SP_Freight _Freight = null;
        public Model.SP_Freight Freight { get { return _Freight; } set { _Freight = this.header1.Freight = value; } }

 
 
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var dc = SiteInfo.CreateDBDataContext())
            {
              
                var merc = dc.SP_Merchandise.FirstOrDefault(p => p.MerchandiseId == MercId && !p.IsDel);

                if (merc == null)
                {
                    throw WarnFactory.CreateWarn("未找到该商品信息，可能该商品已经被删除", WarnIcon.Error, WarnLink.GoDefault);
                }


                

                merc.Hits++;
                dc.SubmitChanges();
                 Merc = merc;
                Freight = merc.SP_Freight;
                this.AirHtml1.Text = merc.Info;
                if (!string.IsNullOrEmpty(this.Merc.Param))
                {
                    var paramList = Newtonsoft.Json.JsonConvert.DeserializeObject<Keyword<string>[]>(this.Merc.Param);
                    this.lvParams.DataSource = paramList;
                    this.lvParams.DataBind();
                }
                //this.lvFreight.DataSource = merc.FreightSetList;
                //this.lvFreight.DataBind();

            }
        }
    }
}
